package cn.wolfcode.mq;

import cn.wolfcode.service.IOrderInfoService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = MQConstant.ORDER_PAY_TIMEOUT_TOPIC,
        consumerGroup = MQConstant.ORDER_PAY_TIMEOUT_TOPIC + "_CUSTOMER_GROUP"
)
public class MQOrderTimeOutListener implements RocketMQListener<OrderMQResult> {
    @Autowired
    private IOrderInfoService orderInfoService;

    /**
     * 监听支付超时消息
     * @param orderMQResult
     */
    @Override
    public void onMessage(OrderMQResult orderMQResult) {
        System.out.println("超时执行力!!!!");
        orderInfoService.cancelTimeOutOrder(orderMQResult);

    }
}
